<template>
  <div class="custom-dropdown" @click.stop>
    <button class="dropdown-trigger">⚙️ 选项 ▼</button>
    <ul v-show="isOpen" class="dropdown-menu">
      <li><a href="/">🏠 首页</a></li>
      <li><a href="/pages/folder/process1.md">📄 文档</a></li>
      <li><a href="https://github.com/your-repo" target="_blank">🐙 GitHub</a></li>
      <li><a href="#" @click.prevent="login">🔑 登录</a></li>
    </ul>
    <div v-if="isOpen" class="dropdown-backdrop" @click="closeMenu"></div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isOpen: false
    }
  },
  mounted() {
    document.addEventListener('click', this.closeMenu)
  },
  beforeDestroy() {
    document.removeEventListener('click', this.closeMenu)
  },
  methods: {
    closeMenu() {
      this.isOpen = false
    },
    login() {
      alert('模拟登录操作')
    }
  }
}
</script>

<style>
.custom-dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-trigger {
  background-color: #fff;
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  color: #555;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: 35px;
  background-color: #fff;
  border: 1px solid #ddd;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  min-width: 150px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.dropdown-menu li a {
  display: block;
  padding: 8px 12px;
  text-decoration: none;
  color: #333;
}

.dropdown-menu li a:hover {
  background-color: #f1f1f1;
}

.dropdown-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent;
  z-index: 999;
}
</style>
